home *** CD-ROM | disk | FTP | other *** search
/ X User Tools / X User Tools (O'Reilly and Associates)(1994).ISO / sources / libxpm / libxpm34.gz / libxpm34 / xpm-3.4 / lib / XpmCrBufFrP.c < prev    next >
C/C++ Source or Header  |  1994-03-14  |  2KB  |  62 lines

  1. /* Copyright 1989-94 GROUPE BULL -- See license conditions in file COPYRIGHT */
  2. /*****************************************************************************\
  3. * XpmCrBufFrP.c:                                                              *
  4. *                                                                             *
  5. *  XPM library                                                                *
  6. *  Scan a pixmap and possibly its mask and create an XPM buffer               *
  7. *                                                                             *
  8. *  Developed by Arnaud Le Hors                                                *
  9. \*****************************************************************************/
  10.  
  11. #include "xpmP.h"
  12. #ifdef VMS
  13. #include "sys$library:string.h"
  14. #else
  15. #if defined(SYSV) || defined(SVR4)
  16. #include <string.h>
  17. #else
  18. #include <strings.h>
  19. #endif
  20. #endif
  21.  
  22. int
  23. XpmCreateBufferFromPixmap(display, buffer_return, pixmap, shapemask,
  24.               attributes)
  25.     Display *display;
  26.     char **buffer_return;
  27.     Pixmap pixmap;
  28.     Pixmap shapemask;
  29.     XpmAttributes *attributes;
  30. {
  31.     XImage *ximage = NULL;
  32.     XImage *shapeimage = NULL;
  33.     unsigned int width = 0;
  34.     unsigned int height = 0;
  35.     int ErrorStatus;
  36.  
  37.     /* get geometry */
  38.     if (attributes && attributes->valuemask & XpmSize) {
  39.     width = attributes->width;
  40.     height = attributes->height;
  41.     }
  42.  
  43.     /* get the ximages */
  44.     if (pixmap)
  45.     xpmCreateImageFromPixmap(display, pixmap, &ximage, &width, &height);
  46.     if (shapemask)
  47.     xpmCreateImageFromPixmap(display, shapemask, &shapeimage,
  48.                  &width, &height);
  49.  
  50.     /* create the buffer */
  51.     ErrorStatus = XpmCreateBufferFromImage(display, buffer_return, ximage,
  52.                        shapeimage, attributes);
  53.  
  54.     /* destroy the ximages */
  55.     if (ximage)
  56.     XDestroyImage(ximage);
  57.     if (shapeimage)
  58.     XDestroyImage(shapeimage);
  59.  
  60.     return (ErrorStatus);
  61. }
  62.